<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-for</title>
    <style>
        [v-cloak] {
            display: none;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        li {
            list-style: none;
        }

        a {
            text-decoration: none;
            color: #000;
        }

        ul {
            display: flex;
            border-bottom: 2px solid rgb(163, 13, 13);
            background: #fff;
            color: #000;
            height: 50px;
            line-height: 50px;
            font-weight: 600;
        }

        ul>li {
            padding: 0 10px;
        }

        .active {
            color: #fff;
            background: rgb(163, 13, 13);
        }

        li.active>a {
            color: #fff;
        }
    </style>
</head>

<body>
    <ul v-cloak>
        <li v-for="(v, i) in arr" @click="select(i)" :key="i" :class="{active: i === activeIndex}">
            <a href="#">{{v.name}}</a>
        </li>

    </ul>
    <script src="./js/dev/vue.js"></script>
    <script>
        const app = new Vue({
            el: 'ul',
            data: {
                arr: [
                    { name: '京东秒杀', },
                    { name: '每日特价', },
                    { name: '品牌秒杀', },
                    { name: '京东到家', },
                ],
                activeIndex: 0
            },
            methods: {
                select(i) {
                    this.activeIndex = i
                }
            }
        })
    </script>
</body>

</html>